package com.example.midprojcampusspringboot.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.midprojcampusspringboot.common.ResultUtil;
import com.example.midprojcampusspringboot.domain.entity.TManagerStudent;
import com.example.midprojcampusspringboot.domain.entity.TManagerTeacher;
import com.example.midprojcampusspringboot.domain.params.TeacherQueryParams;
import com.example.midprojcampusspringboot.service.TeacherService;
import com.github.pagehelper.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Teacher教师管理
 *
 * @Author Fengwei
 * @Description
 * a)新增教师：
 * b)查询教师:根据id查询教师信息；根据教师筛选条件查询教师
 *
 **/
@RestController
@RequestMapping("/teacher")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    /**
     * 1.新增教师
     *
     **/
    @PostMapping("/create")
    public ResultUtil addTeacher(@RequestBody @Validated TManagerTeacher teacher) {
        return teacherService.save(teacher) ? ResultUtil.success("添加成功") : ResultUtil.error("添加失败");
    }

    /**
     * 2.查询教师
     *
     **/
    @PostMapping("/list")
    public ResultUtil listTeacher(@RequestBody TeacherQueryParams params) {
       return ResultUtil.success(teacherService.findTeachersByCriteria(params));
    }
}
